<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title>列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="/css/font.css">
<link rel="stylesheet" href="/css/index.css">
<script type="text/javascript" src="/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/index.js"></script>
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/layui-post.js"></script>
<style>
.layui-table-cell {
    height: auto !important; /* 使用important确保覆盖默认样式 */
    overflow: auto; /* 开启滚动条，如果内容超出设定高度 */
}
.peisong{display: none;}
.ziqu{display: none;}
</style>
</head>
<body>
<div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-body layui-table-body layui-table-main">
                <form class="layui-form layui-form-pane">
                    <div class="layui-tab layui-tab-card">
                        <div class="layui-tab-item layui-show">
                            <div class="layui-col-md6">
                                <label for="sendType" class="layui-form-label"><span class='x-red'>* </span>配送方式</label>
                                <div class="layui-input-block">
                                    <input id="sendType" type="text" readonly name="sendType" autocomplete="off" placeholder="请输入配送方式" lay-verify="required" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <label for="sendTime" class="layui-form-label"><span class='x-red'>* </span>配送时间</label>
                                <div class="layui-input-block">
                                    <input id="sendTime" type="text" readonly name="sendTime" autocomplete="off" placeholder="请输入配送时间" lay-verify="required" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-col-md12 peisong">
                                <label for="address" class="layui-form-label"><span class='x-red'>* </span>收货信息</label>
                                <div class="layui-input-block">
                                    <input id="address" type="text" readonly name="address" autocomplete="off" placeholder="请输入收货信息" lay-verify="required" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-col-md12 peisong">
                                <label for="remark" class="layui-form-label"><span class='x-red'>* </span>订单备注</label>
                                <div class="layui-input-block">
                                    <input id="remark" type="text" readonly name="remark" autocomplete="off" placeholder="请输入订单备注" lay-verify="required" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-col-md12 ziqu">
                                <label for="telPhone" class="layui-form-label"><span class='x-red'>* </span>自取时间</label>
                                <div class="layui-input-block">
                                    <input id="telPhone" type="text" readonly name="telPhone" autocomplete="off" placeholder="请输入订单备注" lay-verify="required" class="layui-input">
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
                <table class="layui-table layui-form" id="table" lay-filter="table"></table>
            </div>
        </div>
    </div>
</div>
</body>
<script>
$.ajaxSetup({contentType: "application/json; charset=utf-8"});
layui.use(['table','form'], function(){
	var table = layui.table
    $.post(geturl()+'/cateringUser/select?token='+sessionStorage.getItem("token"), JSON.stringify({}), function (res) {
        for(var i in res.data) $('#userId').append('<option value="'+res.data[i].userId + '">' + res.data[i].nickName + '</option>');
        layui.form.render();
    })
    $.post(geturl()+'/cateringOrder/select?token='+sessionStorage.getItem("token"), JSON.stringify({sysId:getQueryString("sysId")}), function (res) {
        for(var i in res.data){
            $("#sendTime").val(res.data[i].sendTime)
            if(res.data[i].sendType == 1){
                $(".peisong").show()
                $("#sendType").val('外面配送')
                $("#address").val(res.data[i].person+' '+res.data[i].telPhone+' '+res.data[i].address+' '+res.data[i].detail)
                $("#remark").val(res.data[i].remark)
            }else{
                $(".ziqu").show()
                $("#sendType").val('到店自取')
                $("#telPhone").val(res.data[i].remark)
            }
        }
    })
    table.render({
        elem: 'table', //指定元素
        url:geturl()+'/cateringOrderCart/select?token='+sessionStorage.getItem("token"),
        contentType:'application/json',
        method:'post',
        page:false,
        cellMinWidth: 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
        where:{orderByType: "createTime",orderId:getQueryString("sysId")},
        cols: [[
            //{type: 'checkbox',width: 80},
            {title: '序号',align:"center",halign:"center",width:80,type: 'numbers'},
            {field:'goodsName',align:"center",title:'商品名称',templet:function (e){return '<div style="text-align: left">'+e.goodsName+'</div>'}},
            {field:'goodsNum',align:"center",width:100,title:'商品数量'},
            {field:'goodsPrice',align:"center",width:100,title:'商品价格'},
            {field:'spacesName',align:"center",width:120,title:'商品规格'},
            {field:'spacesName',align:"center",width:150,title:'商品图样',templet:onloadGoodsImg},
            {field:'createTime',align:"center",title: '下单时间',width: 150,},
        ]],
    });
    layui.form.on('switch(switchTest)', function(data){
        var id = data.elem.attributes['data_id'].nodeValue;
        var status = data.elem.attributes['status'].nodeValue;
        var em = $(data.othis[0]);
        layer.confirm('确认'+(status == 0 ? '' : '取消')+'禁用吗？',{icon: 0,title:'提示',cancel:function(){closeSwitch1(data,status,em);}},function(index){
            if(status == 0) layuiPost(geturl()+'/cateringOrder/update?token='+sessionStorage.getItem("token"),{status:1,sysId:id});
            else layuiPost(geturl()+'/cateringOrder/update?token='+sessionStorage.getItem("token"),{status:0,sysId:id});
        },function(index){
            closeSwitch1(data,status,em)
        });
    });
});
function onloadStatus(data){
    if(data.status == 1){
        return '<input type="checkbox" checked="" name="switch" lay-skin="switch" data_id="'+data.sysId+'" status="'+data.status+'" lay-filter="switchTest" lay-text="是|否">'
    }else if(data.status == 0){
        return '<input type="checkbox" name="switch" lay-skin="switch" data_id="'+data.sysId+'" status="'+data.status+'" lay-filter="switchTest" lay-text="是|否">'
    }
}
function onloadGoodsImg(data){
    return '<img src="'+data.goodsImg+'" style="height: 100px;width: 100px;" alt="">'
}

</script>
</html>